<?php
/**
 * 
 * @author Paolo Bertuzzo
 *
 */
namespace User\Data;

class CountryDao extends AbstractDao
{
    
    /**
     * 
     */
    public function get() 
    {
        $query = $this->entityManager->createQuery('select c from User\Entity\Country c');
        
        $query->useResultCache(true);
        
        return $query->getResult();
    }

    /**
     * 
     * @param integer $countryId
     */
    public function getById($countryId)
    {
    	$query = $this->entityManager->createQuery('select c from User\Entity\Country c where c.countryId = ?1');

    	$query->setParameter(1, $countryId);
    	$query->useResultCache(true);

    	$result = $query->getResult();
    	 
        return count($result) == 0 ? null : $result[0];
    }
    
}

?>